Preperation of Pay

	!file 1 pay
	!file 2 payname
	!file 3 payf
	!file 4 payic
	!cfile 5 imp
	!file 6 payx
	!file 7 paytime
	!cfile 8 paytax

	!scroll 9,12
	!temp pass,,a8
	!temp FORCE,,i1
	!box |

.Big temps used in calculations.
	!temp GO,= 1 if all inputs needed,i1
	!temp GO1, = 1 if all inputs always needed,i1
	!temp DI,= 1 if all info to be displayed,i1
	!temp UPdate,= 1 if in display comming from update,i1
	!temp nhrs,To hold md_nhrs,m4
	!temp hol_hrs,Deemed work hrs for holiday fund %age,m4
	!temp payr1,,m8
	!temp payr2,,m8
	!temp payr3,,m8
	!temp payr4,,m8
	!temp ABATE,Abatment,m8
	!temp CHILDS,Children,a1
	!temp STATUS,Holds status,a1
	!temp Date1,used in global date changes,d4
	!temp Date2,ditto,d4

	!temp scrline,,i1
	!temp date,,d4
	!temp time,,m4

	!temp month,Temps for DECDATE,i1
	!temp year,,i2
	!temp Month,,i1
	!temp Year,,i2

	!temp TH,Alfa time hold,a5
	!temp pay1,Pay from rate1,m8
	!temp pay2,,m8
	!temp pay3,,m8
	!temp pay4,Pay from EG Payment,m8
	!temp pay5,Deemed pay while sick or short time,m8

	!temp holR,Holiday fund R,m8
	!temp pay,Tax. pay,m8
	!temp net,Net Pay,m8
        !temp nett,,m8

	!temp dateO,Old date for changing date,d4
	!temp dateN,New date,d4

 +      i_sname, ,1,2
 +      md_date, ,1,53
 +      time, ,1,24,##.##

 +      md_no,No,9,2
 +      m_sname,Name,9,6
 +      md_hr1,N. T.,9,15
 +      md_hr2,O. T.,9,24
 +      md_hr3,Rate3 T.,9,32
 +      md_away,Away,9,60
 +      md_sick,Sick,9,67
 +      md_short,Short,9,74
 +      net,,9,40
 +	md_sck,,9,52

 +      md_rate1,N.T. Rate,3,13
 +      md_rate2,O.T. Rate,4,13
 +      md_rate3,Rate3 Rate,5,13
 +      pay4,E.G. Pay,6,13,####.##

 +      m_status, ,6,55

 +      pay1, ,3,22
 +      pay2, ,4,22
 +      pay3, ,5,22
 +      md_egpay, ,6,22,#######.##

 +      md_holr,Hol fund base,2,42
 +      md_hol,,3,42,##.##%
 +      md_atnd,,4,46
 +      pay,,5,46,#####.##
 +      md_tax,,6,46
 +      holR, ,3,50,R ####.##

 +      md_provEE,,1,73
 +      md_sickEE,,2,73
 +	md_sickAEE,,3,73

 +      md_mortEE,,4,73
 +      md_levyEE,,5,73
 +      md_union,,6,73
 +      md_uif,,7,73
 +      md_rlw,,8,18
 +      md_rtw,,8,46
 +      md_icret,,8,78

 +	pass, ,2,2,e
.	message "Enter password." : input pass : if pass <> " Pians" then exit
	message ""

	open 5
	find 5 nsr = EXIT : i_no = i_cno : read 5 nsr = EXIT
	find 3 key = i_no nsr = EXIT
	md_cno = i_no : m_cno = i_no : mx_cno = i_no : ic_cno = i_no
	close 5 : open 8

 Date   md_date = date : display time ,  md_date , i_sname

 en     message ""
 en1    DI = 0 : md_cno = i_no : GO1 = 0 : FORCE = 0 : end

 * e = Exit
 EXIT   exit

 * *i = inpot
	message "This allows you to input wages , even for those who have left."
	sleep 1
	FORCE = 1

 * i = Input
	message "Enter correct date or <CR> if O.K."
	clear md_icret
	input md_date bs = Date
	scroll 1 : md_no = 2
 i1	message "Input Number of worker" : GO = 0
	if GO1 = 1 then GO = 1
if m_dateout = "" or FORCE = 1 then input md_no bs = en
	m_no = md_no : find 2 nsr = i19
	display time ,  md_no

. Rates of pay
	payr1 = m_pay : payr2 = m_pay * p_ot1 / 100
	payr3 = m_pay * p_ot2 / 100 : payr4 = m_bonus1 + m_bonus2
	md_rate1 = payr1 : md_rate2 = payr2
	md_rate3 = payr3 : pay4 = payr4

	display time ,  md_no , m_sname , md_rate1 - m_status

. Pay & bonus
 i2     message "Input actual hours worked or <CR> if O.K. <bs> if this man did not work."
.       md_hr1 = p_hrs1 : md_hr2 = 0 : md_hr3 = 0

.New bit to pull times from "PAYTIME"
	pt_rate1 = 0 : pt_rate2 = 0 : pt_rate3 = 0 : pt_smk = 0 : pt_smkn = 0
	pt_tea = 0 : pt_tean = 0 : pt_time = 0 : pt_tihold = 0 : pt_ut = 0
	find 7 key = i_no , md_no nsr = i3
 i3     md_smk = pt_smk : md_smkn = pt_smkn : md_ut = pt_ut
	md_tea = pt_tea : md_tean = pt_tean
	md_hr1 = pt_rate1 * 100 : md_hr2 = pt_rate2 * 100 : md_hr3 = pt_rate3 * 100
.       md_hr1 = 4400
	md_rlw = pt_rlw : display time ,  md_hr1 - md_hr3 , md_rlw
	if m_dateout <> "" and FORCE = 0 then goto i19
	input md_hr1 bs = i19
	TH = pt_tihold : if pt_tihold <> 0 then message TH + " hours held for next week."
	input md_hr2 - md_hr3 bs = i19

.Short hours
 i4     md_away = 0 : if md_hr1 < p_hrs1 then md_away = p_hrs1 - md_hr1
	md_sick = 0 : md_short = 0 : display time ,  md_away - md_short
	message "Enter relevant hours or <CR> if O.K. <bs> to change hours."
	input md_away bs = i2 ni = i6
 i5     if md_hr1 + md_away < p_hrs1 then md_sick = p_hrs1 - md_hr1 - md_away
	display time ,  md_sick : input md_sick bs = i4 ni = i6
	if md_hr1 + md_away + md_sick < p_hrs1 then \
	md_short = p_hrs1 - md_hr1 - md_away - md_sick
	display time ,  md_short : input md_short bs = i5
 i6     md_nhrs = p_hrs1
	if UPdate = 1 then return
 i7     message "Input pay rates or <CR> if O.K."
	if GO = 0 then goto i8
	input md_rate1 - pay4 bs = i2
 i8     pay1 = md_rate1 * md_hr1 / p_hrs1
	pay2 = md_rate2 * md_hr2 / p_hrs1
	pay3 = md_rate3 * md_hr3 / p_hrs1
	
	md_egpay = pay4
	if md_hr1 < p_hrs1 then md_egpay = pay4 * md_hr1 / p_hrs1
	pay5 = md_rate1 * (md_sick + md_short) / p_hrs1

	display time ,  md_hr1 - md_hr3 , md_rate1 - md_egpay

. Holiday fund
	md_hol = 0 : hol_hrs = md_hr1 + md_sick + md_short
	if hol_hrs >= p_holhr1 then md_hol = p_hol1
	if hol_hrs >= p_holhr2 then md_hol = p_hol2
	if hol_hrs >= p_holhr3 then md_hol = p_hol3
 i9     if UPdate = 1 then message "This data has been altered. " +\
	"Suggest you <bs> out & re-start." : sleep 3 : return

	md_holr = pay1 + pay2 + pay3 + pay5

 i9a    holR = md_hol * md_holr / 10000
	display time ,  md_holr - holR
	message "Enter holiday fund base rands & rate or <CR> if O.K."
	if GO = 0 then goto i10
	input md_holr , md_hol ni = i10 bs = i7
	goto i9a

. Attendance bonus

 i10    md_atnd = 0
	if md_hr1 > p_atndh then md_atnd = p_atnd
	display time ,  md_atnd
	message "Enter attendance bonus or <CR> if O.K."
	if GO = 0 then goto i11
	input md_atnd bs = i9

. Provident Levy UIF
	message "Input other data or <CR> if O.K."
 i11    md_provEE = 0
	if md_hr1 >= p_provhr then md_provEE = m_oldpay * p_prov / 10000

	md_sickEE = 0
	if md_provEE > 0 then md_sickEE = m_oldpay * p_sick / 10000

	md_mortEE = 0
	if md_provEE > 0 then md_mortEE = p_mort
	md_sickEE = md_sickEE - md_mortEE

.Additional sick fund
	md_sickAEE = 0
	if md_provEE > 0 then md_sickAEE = m_oldpay * p_sickA / 10000

	display time ,  md_provEE - md_mortEE
	if GO = 0 then goto i11g
	input md_provEE - md_mortEE bs = i9
 i11g   md_provER = md_provEE
	md_sickER = md_sickEE
	md_sickAER = md_sickAEE
	md_mortER = md_mortEE

. The decision whether or not to pay levies needs to be tightened up.

 i12    pay = pay1 + pay2 + pay3
	md_levyEE = 0 : if pay >= p_levy then md_levyEE = p_levy
	display time ,  md_levyEE
	if GO = 0 then goto i12g
	input md_levyEE bs = i11
 i12g   md_levyER = md_levyEE

 i13    md_union = 0 : if pay > p_union then md_union = p_union
	display time ,  md_union
	if GO = 0 then goto i15
	input md_union bs = i12
	goto i15
 i14    if UPdate = 1 then message "This data has been altered. " +\
	"Suggest you <bs> out & restart." : sleep 3 : return

 i15    md_uif = 0
.UIF is paid if 1 is paid in the week.
	if md_hr1 >= p_hrs1 / 5 then md_uif = (md_rate1 * p_uif + 5000) / 10000
	display time ,  md_uif
	if GO = 0 then goto i16s
	input md_uif bs = i13
	if UPdate = 1 then return

.Sick pay
 i16s	md_sck = 0 : display md_sck
	message "Enter amount to be paid iro sick pay."
	input md_sck bs = i15

. Tax
 i16	pay = pay1 + pay2 + pay3 + md_egpay + holR + md_atnd + md_sck
	md_tax = 0
	display time ,  pay , md_tax , md_sck
	gosub TAX
.	if GO = 0 then goto i16g
	input md_tax bs = i14
	if UPdate = 1 then return

. Net
 i16g   net = pay - md_provEE - md_sickEE - md_sickAEE - md_mortEE - md_levyEE -\
	md_union - md_uif - holR - md_tax
	display time ,  net
	message "Hit <CR> if O.K. or <bs> if not."
	if md_icret = "" then md_icret = "Y"
	display time ,  md_icret
	if GO = 1 then gosub ICret
	if md_icret <> "Y" then message "Will not print on industrial council return." : sleep 2
	input net bs = i17g
	if UPdate = 1 then return
	gosub Rnd
	insert 1

.Insert into I C cross reference file.
	gosub DecDate : insert 4
.Insert into payx cross reference file. (For IRP5s)
	mx_no = md_no : mx_date = md_date : insert 6
	goto i19
 i17g   GO = 1 : goto i16

 i19    next 2 nsr = i20 : if m_cno <> i_no then m_cno = i_no : goto i1
	md_no = m_no
	if m_dateout = "" or FORCE = 1 then scroll
	display time ,  md_no
	goto i1 

 i20    message "No numbers higher than this." : end

 Rnd    message "Input lastweek round-up"
	if GO = 1 then input md_rlw
	nett = (net - md_rlw) % p_rnd
	if nett = 0 then md_rtw = 0 : goto Rnd1
	md_rtw = (net - md_rlw) - nett + p_rnd - (net - md_rlw)

 Rnd1   display time ,  md_rtw
	if GO = 1 then message "<CR> if round-up OK or change." : input md_rtw
	return

 * d = Display
	scroll 1
 d1     message "Enter date for display"
	input md_date bs = en : md_no = 0 : DI = 1
	find 1 nsr = d2 : md_no = 0 : goto d3
 d2     next 1 nsr = en : if md_cno <> i_no then goto en
	md_no = 0
 d3     message "If just one worker then enter number, else hit <CR>."
	input md_no : find 1
 d4     find 2 key = i_no , md_no nsr = en

	pay1 = md_rate1 * md_hr1 / md_nhrs
	pay2 = md_rate2 * md_hr2 / md_nhrs
	pay3 = md_rate3 * md_hr3 / md_nhrs

	pay = pay1 + pay2 + pay3 : holR = md_hol * md_holr / 10000
	pay = pay + md_egpay + holR + md_atnd

	net = pay - md_provEE - md_sickEE - md_sickAEE - md_mortEE - md_levyEE -\
	md_union - md_uif - holR - md_tax + md_sck

	if DI = 1 or UPdate = 1 then display time ,  md_rate1 - md_uif , md_date , i_sname
	display time ,  md_no - md_sck , md_icret , md_rlw , md_rtw : DI = 0

	if UPdate = 1 then return

	match 1 nsr = CLEAR
	scroll
	if scrline <= 12 then goto d4
	DI = 1 : scroll 1
 d5     message "Hit <CR> for next page or <bs> to end."
	input md_no bs = d1 ni = d4
	goto d5
 CLEAR  scroll : if scrline > 12 then goto CL
	clear md_no - md_sck : goto CLEAR
 CL     if UPdate = 1 then return
	scroll 1 : next 1 nsr = en : if md_cno <> i_no then goto en
	DI = 0 : goto d1

 * u = Update
	scroll 1
 u1     input md_date , md_no bs = en
	find 1
	UPdate = 1 : gosub d4 : UPdate = 0
.Find record in I C cross reference file.
	gosub DecDate : find 4
.Find record in payx cross reference file. (For IRP5s)
	mx_no = md_no : mx_date = md_date : read 6

	message "Enter correct info. Blank out No to delete."

 u2     input md_no bs = en : if md_no = 0 then goto u15
 u3     message "Input hours worked or <CR> if O.K. <bs> back."
	find 2 key = md_cno , md_no nsr = nu1 : display time ,  m_sname , md_no
	input md_hr1 - md_hr3 bs = u2
	goto u4
 nu1    message "Unknown chappie. Start again." : sleep 3 : goto u1
 u4     message "Input rates of pay (R per week), <CR> if O.K. or <bs> back."
	input md_rate1 - pay4 bs = u3
 u5     message "Input the normal hrs per week or <CR> if O.K. (No <bs> here.)"
	nhrs = md_short : md_short = md_nhrs : display time ,  md_short
	input md_short
	md_nhrs = md_short : md_short = nhrs : display time ,  md_short

	pay1 = md_rate1 * md_hr1 / md_nhrs
	pay2 = md_rate2 * md_hr2 / md_nhrs
	pay3 = md_rate3 * md_hr3 / md_nhrs
	md_egpay = pay4
	if md_hr1 < md_nhrs then md_egpay = pay4 * md_hr1 / md_nhrs
	message "Input EG payment or <CR> if OK."
	input md_egpay bs = u4

	pay = pay1 + pay2 + pay3 : holR = md_hol * md_holr / 10000 : display time ,  holR
 u6     message "Input holiday fund base rands & %age or <CR> if O.K. <bs> back."
	input md_holr , md_hol bs = u4
	holR = md_hol * md_holr / 10000 : pay = pay + holR : display time ,  md_holr - holR
 u7     message "Input attendance bonus or <CR> if O.K. <bs> back."
	input md_atnd bs = u6
 u8     UPdate = 1 : GO = 1
	message "<bs> for default values of this data, enter anew or <CR> if O.K."
	input md_provEE - md_uif , md_sck bs = u9
	md_provER = md_provEE : md_sickER = md_sickEE : md_sickAER = md_sickAEE : md_mortER = md_mortEE
	goto u10
 u9     gosub i11
 u10    message "Enter new tax value, <CR> if O.K. or <bs> for default."
	pay = pay1 + pay2 + pay3 + md_egpay + md_atnd + holR + md_sck : display time ,  pay
	input md_tax bs = u11
	goto u12
 u11    gosub i16
 u12    message "<bs> for re_calculated values, <CR> if O.K."
	input md_away - md_short bs = u13
	gosub ICret : goto u14
 u13    gosub i4
 u14    message "" : UPdate = 0 : GO = 0
.	prompt "All O.K. to write" no = u16
 u15    if md_no = 0 then prompt "Delete this one, sure" no = u16 :\
	delete 1 : delete 4 : delete 6 : goto u16
	write 1
.Write to I C cross reference file.
	gosub DecDate : write 4
.Write to payx cross reference file. (For IRP5s)
	mx_no = md_no : mx_date = md_date : write 6

 u16    next 1 nsr = u17 : if md_cno <> i_no then md_cno = i_no : goto u17
	goto u1
 u17    message "No more........." : sleep 2 : message "" : goto u1
 ICret  message 'An "N" will exclude from printed I.C. return. A "Y" will include.'
	input md_icret bs = ICr
.       if md_icret <> "Y" then prompt "Sure" no = i16g
	return
 ICr    if md_icret = "Y" then md_icret = "N" : goto ICret
	if md_icret <> "Y" then md_icret = "Y" : goto ICret
........
. Cross reference file for Ind Council return.
 DecDate\
	decdate md_date
	ic_month = month : ic_year = year
	ic_no = md_no : ic_date = md_date
	return
........
 TAX    x_status = "M"

	find 8 key = x_status nsr = HELP1
 X1     if pay / 100 * 52 >= x_rand1 and pay / 100 * 52 < x_rand2 then goto X2
	match 8 nsr = HELP2
	goto X1
 X2     ABATE = 5800

 RET    md_tax = ((x_tax * 100 + (pay * 52 - x_rand1 * 100) * x_margin / 100) - ABATE * 100)/ 52
.       if x_status = "M" then md_tax = md_tax + 600
	if md_tax < 0 then md_tax = 0
	display time ,  md_tax : return
	
 HELP1  message "Help! Unknown status." : goto en1
 HELP2  message "Help! Too much pay for this man's tax." : goto en1
 NM     m_sname = pay: display time ,  m_sname : sleep 3 : return
. *a = Date
. Note: Do not use this part until the file 4 & 6 cross references are done.
 da1    message "Enter the existing date"
 da2    input md_date bs = en : Date1 = md_date
	find 1 key = i_no , md_date nsr = D1 : display time ,  md_date - md_icret
	message "Enter the date these entries shound be"
	input md_date bs = da2 : Date2 = md_date
	find 1 key = i_no , Date1 : find 4 key = i_no
 da3    md_date = Date2 : display time ,  md_date - md_icret
	write 1
	match 1 nsr = D2 : goto da3
 D1     message "No such date on record." : goto en
 D2     message "All done" : goto da1
........

 *c = Change date
	message "Global change of one date to another." : sleep 2
 c1     message "Enter old (wrong) date."
	input md_date bs = en : dateO = md_date
	message "Enter new date."
	input md_date bs = c1 : dateN = md_date
	decdate dateN : Year = year : Month = month
	md_no = 0 : find 1 key = i_cno , dateO nsr = Cnone
 c2     ic_cno = md_cno
	decdate md_date : ic_year = year : ic_month = month
	ic_no = md_no : ic_date = md_date : find 4
	ic_year = Year : ic_month = Month : ic_date = dateN

	find 6 key = i_cno , md_no , md_date : mx_date = dateN

	md_date = dateN
	m_sname = "Unknown" : find 2 key = i_cno , md_no nsr = c3
 c3     display time ,  md_date - md_icret
	write 1 : write 4 : write 6
	match 1 nsr = Cnone : goto c2

 Cnone  message "End of this date or none found." : goto en1
 *a = Input All
	prompt "Do you want to be prompted for all inputs" no = en
	GO1 = 1 : end
.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
